package com.springmvc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/4/20.
 */

@Service("commonDao")
public class CommonDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    public void getUserById() {

        String sql = "select * from user";
        List<Map<String, Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> re : res) {
            for (Map.Entry<String, Object> map : re.entrySet()) {
                System.out.print(map.getKey() + " --> " + map.getValue());
            }
            System.out.println("");
        }

    }

}
